<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>

<script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery.livequery.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery.validate.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery.validate.extend.js"></script>

<script type="text/javascript" src="${pageContext.request.contextPath }/js/My97DatePicker/WdatePicker.js"></script>


<div class="module">
   <p class="title">新增管理员
		<span class="title-tools">
	  		<a href="javascript: void(0);" class="asideBtn" onclick="javascript: getManagerList('${param.site}');">返回</a>
	  	</span>
   </p>
   
   <c:set var="readonly" />
   <c:if test="${null!=manager }">
   		<c:set value="readonly='readonly'" var="readonly"/>
   </c:if>
   
   <form id="form">
   		<div class="content">
       	   <br>
			<ul class="summary-table" style="width: 95%; margin: auto auto">
				<li>
					<label class="col1">用户名</label>
					<span class="col2">
						<c:if test="${null==manager }">
							<input class="ctr-input" id="userName" name="userName" value="${null==manager?'':manager.userName }" data-vdt="required rangelength 3 20 #字符长度范围[6-20] remote ${pageContext.request.contextPath }/view/checkAccount #该帐号已被使用"/>
						</c:if>
						<c:if test="${null!=manager }">
							<input class="ctr-input" id="userName" name="userName" value="${null==manager?'':manager.userName }" ${readonly }/>
						</c:if>
					</span>
				</li>

				<li>
					<label class="col1">手机号</label> 
					<span class="col2">
						<input class="ctr-input" id="mobile" name="mobile" value="${null==manager?'':manager.mobile }" />
					</span>
				</li>

				<li>
					<label class="col1">密 码</label>
					<span class="col2">
						<input type="password" class="ctr-input" id="password" name="password"/>
					</span>
				</li>
			</ul>
			<c:if test="${null!=manager }">
				<input class="ctr-input" name="id" value="${manager.id }" type="hidden" />
			</c:if>
			<div class="form-button-group" style="margin: auto auto">
				<span class="form-button saveBtn" id="updateSubmit">保存</span>
			</div>

		</div>
    </form>
</div>
<script type="text/javascript">
	$('#updateSubmit').bind('click', function() {
		handleManager();
	});

	function handleManager() {
		if ($("#form").valid()) {
			$.ajax({
				type : "POST",
				url : contextPath + "/web/managerCenter/handleManager",
				data : $("#form").serialize(),
				dataType : "json",
				beforeSend : function() {
					$("#beforeLoading").show();
				},
				success : function(res) {
					$("#beforeLoading").hide();
					if (res.resData.status) {

						succHint();

						setTimeout(function() {
							getManagerList();
						}, 2500);

					} else {
						failHint(res.msg);
					}

				},
				error : function(msg) {
					$("#beforeLoading").hide();
					failHint();
				}
			});
		}
	}
</script>

